home *** CD-ROM | disk | FTP | other *** search
/ Amiga Inside! / Amiga FD Inside (1995)(Ultramax).iso / berndspd / devtools / intuigen / examples / cardfile.c next >
Encoding:
C/C++ Source or Header  |  1993-12-22  |  17.5 KB  |  1,092 lines

  1. #include <stddef.h>
  2. #include <stdlib.h>
  3. #include <exec/exec.h>       /* These 4 files are system includes */
  4. #include <intuition/intuition.h>
  5. #include <IntuiGen/IntuiGen.h>
  6. #include <IntuiGen/IGRequest.h>
  7.  
  8. /* APTR is defined as a void * */
  9.  
  10. APTR IntuitionBase,GfxBase;  /* These will be initialized to point to
  11.                 system library structures facilitating
  12.                 the use of system routines */
  13.  
  14. struct Person {   /* This is our data structure which we will be storing
  15.             data IGRequest gets from the user into */
  16.     struct Person *Next,*Prev;
  17.     UBYTE       Name[100],
  18.            Address[100],
  19.            CityStateZip[100];
  20.     SHORT       Age;
  21. };
  22.  
  23. /* IGRequest uses information about the offsets of fields and field type
  24.     that is supplied to it in the linked lists/trees of data structures
  25.     passed to it
  26. */
  27.  
  28.  
  29. /* struct Person is the data struct that will store the information typed
  30.     into each card */
  31.  
  32. struct Remember *CardKey=0;  /* Remember keys are a convenient way to keep
  33.                    track of allocated memory on the Amiga */
  34.  
  35. struct Person CardBase,*OnScreen=0;
  36. BOOL QuitFlag=0;  /* BOOL is typedefed to ULONG (unsigned long) */
  37.  
  38. /* The preceding variable declarations are for management of the linked list
  39.     used to store data, memory allocation, and deciding when it is time
  40.     to terminate program execution
  41. */
  42.  
  43.  
  44.  
  45. void LoadStuff(struct IGRequest *,struct IntuiMessage *);
  46. void SaveStuff(struct IGRequest *,struct IntuiMessage *);
  47. void Quit     (struct IGRequest *,struct IntuiMessage *);
  48.  
  49. /* The preceding are function prototypes which describe functions that
  50.     we will enter later, the return value they give, and the type
  51.     of arguments they require.
  52. */
  53.  
  54. /*  Everything after this is IntuiGen generated */
  55.  
  56.  
  57. /* for simplicity, and to save time, we will copy code from a finished version
  58.     of this program to this file instead of manually typing it
  59. */
  60.  
  61. /* Note however that IntuiGen generated 905 lines of code (Line numbers
  62.     are in the top left corner of the windows title bar)
  63. */
  64.  
  65. /* I just deleted out the old, incorrect code */
  66. /* We just inserted the new, mostly correct version */
  67. /* One small change to make... */
  68.  
  69. struct TextAttr TextAttributes0 =
  70. {
  71.     "topaz.font",
  72.     TOPAZ_EIGHTY,
  73.     NULL,
  74.     FPF_ROMFONT
  75. };
  76.  
  77. struct IntuiText ProjectItem3Text =
  78. {
  79.     0,1,
  80.     JAM2,
  81.     18,1,
  82.     &TextAttributes0,
  83.     (UBYTE *)"Quit",
  84.     NULL
  85. };
  86.  
  87. struct MenuItem ProjectItem3 =
  88. {
  89.     NULL,
  90.     1,30,
  91.     92,10,
  92.     ITEMENABLED | ITEMTEXT | HIGHCOMP,
  93.     0,
  94.     (APTR)&ProjectItem3Text,
  95.     NULL,
  96.     0,
  97.     NULL,
  98.     0
  99. };
  100.  
  101. struct IntuiText ProjectItem1Text =
  102. {
  103.     0,1,
  104.     JAM2,
  105.     18,1,
  106.     &TextAttributes0,
  107.     (UBYTE *)"Save",
  108.     NULL
  109. };
  110.  
  111. struct MenuItem ProjectItem1 =
  112. {
  113.     &ProjectItem3,
  114.     1,10,
  115.     92,10,
  116.     ITEMENABLED | ITEMTEXT | HIGHCOMP,
  117.     0,
  118.     (APTR)&ProjectItem1Text,
  119.     NULL,
  120.     0,
  121.     NULL,
  122.     0
  123. };
  124.  
  125. struct IntuiText ProjectItem0Text =
  126. {
  127.     0,1,
  128.     JAM2,
  129.     18,1,
  130.     &TextAttributes0,
  131.     (UBYTE *)"Load",
  132.     NULL
  133. };
  134.  
  135. struct MenuItem ProjectItem0 =
  136. {
  137.     &ProjectItem1,
  138.     1,0,
  139.     92,10,
  140.     ITEMENABLED | ITEMTEXT | HIGHCOMP,
  141.     0,
  142.     (APTR)&ProjectItem0Text,
  143.     NULL,
  144.     0,
  145.     NULL,
  146.     0
  147. };
  148.  
  149. struct Menu Project =
  150. {
  151.     NULL,
  152.     2,0,
  153.     60,10,
  154.     MENUENABLED,
  155.     (BYTE *)"Project",
  156.     &ProjectItem0,
  157.     0,0,0,0
  158. };
  159.  
  160. SHORT CardFileBorderValues1[] = {0,124,0,0,425,0,424,1,1,1,1,123};
  161.  
  162. SHORT CardFileBorderValues2[] = {0,124,425,124,425,0,424,1,424,123,1,123};
  163.  
  164. struct Border CardFileBorderB2 =
  165. {
  166.     11,14,
  167.     2,0,
  168.     JAM1,
  169.     6,
  170.     CardFileBorderValues1,
  171.     NULL
  172. };
  173.  
  174. struct Border CardFileBorderB1 =
  175. {
  176.     11,14,
  177.     1,0,
  178.     JAM1,
  179.     6,
  180.     CardFileBorderValues2,
  181.     &CardFileBorderB2
  182. };
  183.  
  184. struct TextAttr TextAttributes1 =
  185. {
  186.     "topaz.font",
  187.     TOPAZ_SIXTY,
  188.     FSF_UNDERLINED | FSF_BOLD | FSF_ITALIC | FSF_EXTENDED,
  189.     FPF_ROMFONT
  190. };
  191.  
  192. struct IntuiText Title =
  193. {
  194.     1,0,
  195.     JAM2,
  196.     28,17,
  197.     &TextAttributes1,
  198.     (UBYTE *)"IntuiGen Generated Card File",
  199.     NULL
  200. };
  201.  
  202. struct IntuiText NewGadText1 =
  203. {
  204.     1,0,
  205.     JAM2,
  206.     30,3,
  207.     &TextAttributes0,
  208.     (UBYTE *)"Ne",
  209.     NULL
  210. };
  211.  
  212. struct TextAttr TextAttributes2 =
  213. {
  214.     "topaz.font",
  215.     TOPAZ_EIGHTY,
  216.     FSF_UNDERLINED,
  217.     FPF_ROMFONT
  218. };
  219.  
  220. struct IntuiText NewGadText2 =
  221. {
  222.     1,0,
  223.     JAM2,
  224.     46,3,
  225.     &TextAttributes2,
  226.     (UBYTE *)"w",
  227.     &NewGadText1
  228. };
  229.  
  230. SHORT NewGadValues1[] = {0,13,0,0,84,0,83,1,1,1,1,12};
  231.  
  232. SHORT NewGadValues2[] = {0,13,84,13,84,0,83,1,83,12,1,12};
  233.  
  234. struct Border NewGadB2 =
  235. {
  236.     0,0,
  237.     2,0,
  238.     JAM1,
  239.     6,
  240.     NewGadValues1,
  241.     NULL
  242. };
  243.  
  244. struct Border NewGadB1 =
  245. {
  246.     0,0,
  247.     1,0,
  248.     JAM1,
  249.     6,
  250.     NewGadValues2,
  251.     &NewGadB2
  252. };
  253.  
  254. struct Border NewGadSelectedB2 =
  255. {
  256.     0,0,
  257.     1,0,
  258.     JAM1,
  259.     6,
  260.     NewGadValues1,
  261.     NULL
  262. };
  263.  
  264. struct Border NewGadSelectedB1 =
  265. {
  266.     0,0,
  267.     2,0,
  268.     JAM1,
  269.     6,
  270.     NewGadValues2,
  271.     &NewGadSelectedB2
  272. };
  273.  
  274. struct IGBoolInfo NewGadIGInfo =
  275. {
  276.     GADG_BOOL,
  277.     NULL,
  278.     0,0,
  279.     NULL,
  280.     NULL,
  281.     NULL,
  282.     NULL,
  283.     (UBYTE *)"New",
  284.     NULL
  285. };
  286.  
  287. struct Gadget NewGad =
  288. {
  289.     NULL,
  290.     332,106,
  291.     84,13,
  292.     GFLG_GADGHIMAGE,
  293.     GACT_RELVERIFY,
  294.     GTYP_BOOLGADGET,
  295.     (APTR)&NewGadB1,
  296.     (APTR)&NewGadSelectedB1,
  297.     &NewGadText2,
  298.     NULL,
  299.     NULL,
  300.     2,
  301.     (APTR)&NewGadIGInfo
  302. };
  303.  
  304. struct IntuiText PreviousGadText1 =
  305. {
  306.     1,0,
  307.     JAM2,
  308.     10,3,
  309.     &TextAttributes2,
  310.     (UBYTE *)"P",
  311.     NULL
  312. };
  313.  
  314. struct IntuiText PreviousGadText2 =
  315. {
  316.     1,0,
  317.     JAM2,
  318.     18,3,
  319.     &TextAttributes0,
  320.     (UBYTE *)"revious",
  321.     &PreviousGadText1
  322. };
  323.  
  324. SHORT PreviousGadValues1[] = {0,13,0,0,84,0,83,1,1,1,1,12};
  325.  
  326. SHORT PreviousGadValues2[] = {0,13,84,13,84,0,83,1,83,12,1,12};
  327.  
  328. struct Border PreviousGadB2 =
  329. {
  330.     0,0,
  331.     2,0,
  332.     JAM1,
  333.     6,
  334.     PreviousGadValues1,
  335.     NULL
  336. };
  337.  
  338. struct Border PreviousGadB1 =
  339. {
  340.     0,0,
  341.     1,0,
  342.     JAM1,
  343.     6,
  344.     PreviousGadValues2,
  345.     &PreviousGadB2
  346. };
  347.  
  348. struct Border PreviousGadSelectedB2 =
  349. {
  350.     0,0,
  351.     1,0,
  352.     JAM1,
  353.     6,
  354.     PreviousGadValues1,
  355.     NULL
  356. };
  357.  
  358. struct Border PreviousGadSelectedB1 =
  359. {
  360.     0,0,
  361.     2,0,
  362.     JAM1,
  363.     6,
  364.     PreviousGadValues2,
  365.     &PreviousGadSelectedB2
  366. };
  367.  
  368. struct IGBoolInfo PreviousGadIGInfo =
  369. {
  370.     GADG_BOOL,
  371.     NULL,
  372.     0,0,
  373.     NULL,
  374.     NULL,
  375.     NULL,
  376.     NULL,
  377.     (UBYTE *)"Previous",
  378.     NULL
  379. };
  380.  
  381. struct Gadget PreviousGad =
  382. {
  383.     &NewGad,
  384.     247,106,
  385.     84,13,
  386.     GFLG_GADGHIMAGE,
  387.     GACT_RELVERIFY,
  388.     GTYP_BOOLGADGET,
  389.     (APTR)&PreviousGadB1,
  390.     (APTR)&PreviousGadSelectedB1,
  391.     &PreviousGadText2,
  392.     NULL,
  393.     NULL,
  394.     1,
  395.     (APTR)&PreviousGadIGInfo
  396. };
  397.  
  398. struct IntuiText NextGadText1 =
  399. {
  400.     1,0,
  401.     JAM2,
  402.     26,3,
  403.     &TextAttributes0,
  404.     (UBYTE *)"Ne",
  405.     NULL
  406. };
  407.  
  408. struct IntuiText NextGadText2 =
  409. {
  410.     1,0,
  411.     JAM2,
  412.     42,3,
  413.     &TextAttributes2,
  414.     (UBYTE *)"x",
  415.     &NextGadText1
  416. };
  417.  
  418. struct IntuiText NextGadText3 =
  419. {
  420.     1,0,
  421.     JAM2,
  422.     50,3,
  423.     &TextAttributes0,
  424.     (UBYTE *)"t",
  425.     &NextGadText2
  426. };
  427.  
  428. SHORT NextGadValues1[] = {0,13,0,0,84,0,83,1,1,1,1,12};
  429.  
  430. SHORT NextGadValues2[] = {0,13,84,13,84,0,83,1,83,12,1,12};
  431.  
  432. struct Border NextGadB2 =
  433. {
  434.     0,0,
  435.     2,0,
  436.     JAM1,
  437.     6,
  438.     NextGadValues1,
  439.     NULL
  440. };
  441.  
  442. struct Border NextGadB1 =
  443. {
  444.     0,0,
  445.     1,0,
  446.     JAM1,
  447.     6,
  448.     NextGadValues2,
  449.     &NextGadB2
  450. };
  451.  
  452. struct Border NextGadSelectedB2 =
  453. {
  454.     0,0,
  455.     1,0,
  456.     JAM1,
  457.     6,
  458.     NextGadValues1,
  459.     NULL
  460. };
  461.  
  462. struct Border NextGadSelectedB1 =
  463. {
  464.     0,0,
  465.     2,0,
  466.     JAM1,
  467.     6,
  468.     NextGadValues2,
  469.     &NextGadSelectedB2
  470. };
  471.  
  472. struct IGBoolInfo NextGadIGInfo =
  473. {
  474.     GADG_BOOL,
  475.     NULL,
  476.     0,0,
  477.     NULL,
  478.     NULL,
  479.     NULL,
  480.     NULL,
  481.     (UBYTE *)"Next",
  482.     NULL
  483. };
  484.  
  485. struct Gadget NextGad =
  486. {
  487.     &PreviousGad,
  488.     162,106,
  489.     84,13,
  490.     GFLG_GADGHIMAGE,
  491.     GACT_RELVERIFY,
  492.     GTYP_BOOLGADGET,
  493.     (APTR)&NextGadB1,
  494.     (APTR)&NextGadSelectedB1,
  495.     &NextGadText3,
  496.     NULL,
  497.     NULL,
  498.     0,
  499.     (APTR)&NextGadIGInfo
  500. };
  501.  
  502. struct IntuiText AgeGadText1 =
  503. {
  504.     1,0,
  505.     JAM2,
  506.     -42,0,
  507.     &TextAttributes0,
  508.     (UBYTE *)"A",
  509.     NULL
  510. };
  511.  
  512. struct IntuiText AgeGadText2 =
  513. {
  514.     1,0,
  515.     JAM2,
  516.     -34,0,
  517.     &TextAttributes2,
  518.     (UBYTE *)"g",
  519.     &AgeGadText1
  520. };
  521.  
  522. struct IntuiText AgeGadText3 =
  523. {
  524.     1,0,
  525.     JAM2,
  526.     -26,0,
  527.     &TextAttributes0,
  528.     (UBYTE *)"e:",
  529.     &AgeGadText2
  530. };
  531.  
  532. SHORT AgeGadValues1[] = {3,12,197,12,197,2,197,12,198,12,198,1,199,0,
  533.         1,0,1,12,0,13,0,0};
  534.  
  535. SHORT AgeGadValues2[] = {197,1,3,1,3,11,3,1,2,1,2,12,1,13,
  536.         199,13,199,1,200,0,200,13};
  537.  
  538. struct Border AgeGadB2 =
  539. {
  540.     -5,-3,
  541.     2,0,
  542.     JAM1,
  543.     11,
  544.     AgeGadValues1,
  545.     NULL
  546. };
  547.  
  548. struct Border AgeGadB1 =
  549. {
  550.     -5,-3,
  551.     1,0,
  552.     JAM1,
  553.     11,
  554.     AgeGadValues2,
  555.     &AgeGadB2
  556. };
  557.  
  558. struct IGStringInfo AgeGadIGInfo =
  559. {
  560.     GADG_STRING | STRING_SHORT | STRING_FILL | STRING_HIGHLIMIT |
  561.     STRING_LOWLIMIT,
  562.     NULL,
  563.     NULL,
  564.     offsetof (struct Person,Age),
  565.     150,1,
  566.     NULL,
  567.     NULL,
  568.     NULL,
  569.     NULL,
  570.     NULL,
  571.     (UBYTE *)"Age:",
  572.     NULL
  573. };
  574.  
  575. struct StringInfo AgeGadInfo =
  576. {
  577.     0,0,0,5,0,0,0,0,0,0,0,0,0
  578. };
  579.  
  580. struct Gadget AgeGad =
  581. {
  582.     &NextGad,
  583.     180,80,
  584.     192,10,
  585.     GFLG_GADGHCOMP | GFLG_TABCYCLE,
  586.     GACT_RELVERIFY | GACT_IMMEDIATE | GACT_LONGINT,
  587.     GTYP_STRGADGET,
  588.     (APTR)&AgeGadB1,
  589.     NULL,
  590.     &AgeGadText3,
  591.     NULL,
  592.     (APTR)&AgeGadInfo,
  593.     3,
  594.     (APTR)&AgeGadIGInfo
  595. };
  596.  
  597. struct IntuiText CityStateZipGadText1 =
  598. {
  599.     1,0,
  600.     JAM2,
  601.     -146,0,
  602.     &TextAttributes2,
  603.     (UBYTE *)"C",
  604.     NULL
  605. };
  606.  
  607. struct IntuiText CityStateZipGadText2 =
  608. {
  609.     1,0,
  610.     JAM2,
  611.     -138,0,
  612.     &TextAttributes0,
  613.     (UBYTE *)"ity, State, Zip:",
  614.     &CityStateZipGadText1
  615. };
  616.  
  617. SHORT CityStateZipGadValues1[] = {3,12,197,12,197,2,197,12,198,12,198,1,199,0,
  618.         1,0,1,12,0,13,0,0};
  619.  
  620. SHORT CityStateZipGadValues2[] = {197,1,3,1,3,11,3,1,2,1,2,12,1,13,
  621.         199,13,199,1,200,0,200,13};
  622.  
  623. struct Border CityStateZipGadB2 =
  624. {
  625.     -5,-3,
  626.     2,0,
  627.     JAM1,
  628.     11,
  629.     CityStateZipGadValues1,
  630.     NULL
  631. };
  632.  
  633. struct Border CityStateZipGadB1 =
  634. {
  635.     -5,-3,
  636.     1,0,
  637.     JAM1,
  638.     11,
  639.     CityStateZipGadValues2,
  640.     &CityStateZipGadB2
  641. };
  642.  
  643. struct IGStringInfo CityStateZipGadIGInfo =
  644. {
  645.     GADG_STRING | STRING_FILL,
  646.     NULL,
  647.     NULL,
  648.     offsetof (struct Person,CityStateZip),
  649.     0,0,
  650.     &AgeGad,
  651.     NULL,
  652.     NULL,
  653.     NULL,
  654.     NULL,
  655.     (UBYTE *)"City, State, Zip:",
  656.     NULL
  657. };
  658.  
  659. struct StringInfo CityStateZipGadInfo =
  660. {
  661.     0,0,0,50,0,0,0,0,0,0,0,0,0
  662. };
  663.  
  664. struct Gadget CityStateZipGad =
  665. {
  666.     &AgeGad,
  667.     180,65,
  668.     192,10,
  669.     GFLG_GADGHCOMP | GFLG_TABCYCLE,
  670.     GACT_RELVERIFY | GACT_IMMEDIATE,
  671.     GTYP_STRGADGET,
  672.     (APTR)&CityStateZipGadB1,
  673.     NULL,
  674.     &CityStateZipGadText2,
  675.     NULL,
  676.     (APTR)&CityStateZipGadInfo,
  677.     2,
  678.     (APTR)&CityStateZipGadIGInfo
  679. };
  680.  
  681. struct IntuiText AddressGadText1 =
  682. {
  683.     1,0,
  684.     JAM2,
  685.     -74,0,
  686.     &TextAttributes0,
  687.     (UBYTE *)"A",
  688.     NULL
  689. };
  690.  
  691. struct IntuiText AddressGadText2 =
  692. {
  693.     1,0,
  694.     JAM2,
  695.     -66,0,
  696.     &TextAttributes2,
  697.     (UBYTE *)"d",
  698.     &AddressGadText1
  699. };
  700.  
  701. struct IntuiText AddressGadText3 =
  702. {
  703.     1,0,
  704.     JAM2,
  705.     -58,0,
  706.     &TextAttributes0,
  707.     (UBYTE *)"dress:",
  708.     &AddressGadText2
  709. };
  710.  
  711. SHORT AddressGadValues1[] = {3,12,197,12,197,2,197,12,198,12,198,1,199,0,
  712.         1,0,1,12,0,13,0,0};
  713.  
  714. SHORT AddressGadValues2[] = {197,1,3,1,3,11,3,1,2,1,2,12,1,13,
  715.         199,13,199,1,200,0,200,13};
  716.  
  717. struct Border AddressGadB2 =
  718. {
  719.     -5,-3,
  720.     2,0,
  721.     JAM1,
  722.     11,
  723.     AddressGadValues1,
  724.     NULL
  725. };
  726.  
  727. struct Border AddressGadB1 =
  728. {
  729.     -5,-3,
  730.     1,0,
  731.     JAM1,
  732.     11,
  733.     AddressGadValues2,
  734.     &AddressGadB2
  735. };
  736.  
  737. struct IGStringInfo AddressGadIGInfo =
  738. {
  739.     GADG_STRING | STRING_FILL,
  740.     NULL,
  741.     NULL,
  742.     offsetof (struct Person,Address),
  743.     0,0,
  744.     &CityStateZipGad,
  745.     NULL,
  746.     NULL,
  747.     NULL,
  748.     NULL,
  749.     (UBYTE *)"Address:",
  750.     NULL
  751. };
  752.  
  753. struct StringInfo AddressGadInfo =
  754. {
  755.     0,0,0,50,0,0,0,0,0,0,0,0,0
  756. };
  757.  
  758. struct Gadget AddressGad =
  759. {
  760.     &CityStateZipGad,
  761.     180,50,
  762.     192,10,
  763.     GFLG_GADGHCOMP | GFLG_TABCYCLE,
  764.     GACT_RELVERIFY | GACT_IMMEDIATE,
  765.     GTYP_STRGADGET,
  766.     (APTR)&AddressGadB1,
  767.     NULL,
  768.     &AddressGadText3,
  769.     NULL,
  770.     (APTR)&AddressGadInfo,
  771.     1,
  772.     (APTR)&AddressGadIGInfo
  773. };
  774.  
  775. struct IntuiText NameGadText1 =
  776. {
  777.     1,0,
  778.     JAM2,
  779.     -50,0,
  780.     &TextAttributes0,
  781.     (UBYTE *)"N",
  782.     NULL
  783. };
  784.  
  785. struct IntuiText NameGadText2 =
  786. {
  787.     1,0,
  788.     JAM2,
  789.     -42,0,
  790.     &TextAttributes2,
  791.     (UBYTE *)"a",
  792.     &NameGadText1
  793. };
  794.  
  795. struct IntuiText NameGadText3 =
  796. {
  797.     1,0,
  798.     JAM2,
  799.     -34,0,
  800.     &TextAttributes0,
  801.     (UBYTE *)"me:",
  802.     &NameGadText2
  803. };
  804.  
  805. SHORT NameGadValues1[] = {3,12,197,12,197,2,197,12,198,12,198,1,199,0,
  806.         1,0,1,12,0,13,0,0};
  807.  
  808. SHORT NameGadValues2[] = {197,1,3,1,3,11,3,1,2,1,2,12,1,13,
  809.         199,13,199,1,200,0,200,13};
  810.  
  811. struct Border NameGadB2 =
  812. {
  813.     -5,-3,
  814.     2,0,
  815.     JAM1,
  816.     11,
  817.     NameGadValues1,
  818.     NULL
  819. };
  820.  
  821. struct Border NameGadB1 =
  822. {
  823.     -5,-3,
  824.     1,0,
  825.     JAM1,
  826.     11,
  827.     NameGadValues2,
  828.     &NameGadB2
  829. };
  830.  
  831. struct IGStringInfo NameGadIGInfo =
  832. {
  833.     GADG_STRING | STRING_FILL,
  834.     NULL,
  835.     NULL,
  836.     offsetof (struct Person,Name),
  837.     0,0,
  838.     &AddressGad,
  839.     NULL,
  840.     NULL,
  841.     NULL,
  842.     NULL,
  843.     (UBYTE *)"Name:",
  844.     NULL
  845. };
  846.  
  847. struct StringInfo NameGadInfo =
  848. {
  849.     0,0,0,50,0,0,0,0,0,0,0,0,0
  850. };
  851.  
  852. struct Gadget NameGad =
  853. {
  854.     &AddressGad,
  855.     180,35,
  856.     192,10,
  857.     GFLG_GADGHCOMP | GFLG_TABCYCLE,
  858.     GACT_RELVERIFY | GACT_IMMEDIATE,
  859.     GTYP_STRGADGET,
  860.     (APTR)&NameGadB1,
  861.     NULL,
  862.     &NameGadText3,
  863.     NULL,
  864.     (APTR)&NameGadInfo,
  865.     0,
  866.     (APTR)&NameGadIGInfo
  867. };
  868.  
  869. struct Window *CardFileWindow;
  870.  
  871. struct NewWindow NewCardFileWindow =
  872. {
  873.     21,15,
  874.     449,149,
  875.     0,1,
  876.     IDCMP_GADGETDOWN | IDCMP_GADGETUP | IDCMP_MENUPICK | IDCMP_RAWKEY,
  877.     WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SMART_REFRESH | WFLG_ACTIVATE,
  878.     NULL,
  879.     NULL,
  880.     (UBYTE *)"IG Card File",
  881.     NULL,
  882.     NULL,
  883.     449,149,
  884.     449,149,
  885.     WBENCHSCREEN
  886. };
  887.  
  888. struct IGEndList CardRequestEndList[] =
  889. {
  890.     { IDCMP_GADGETUP,0,0,&NewGad,NULL,NULL,1 },
  891.     { IDCMP_GADGETUP,0,0,&PreviousGad,NULL,NULL,1 },
  892.     { IDCMP_GADGETUP,0,0,&NextGad,NULL,NULL,1 },
  893.     { IDCMP_RAWKEY,51,8,NULL,NULL,NULL,1 },
  894.     { 0xffffffff,0,0,0,0,0 }
  895. };
  896.  
  897. struct IGKeyCommand CardRequestCommands[] =
  898. {
  899.     { 0,'w',0,&NewGad },
  900.     { 0,'p',0,&PreviousGad },
  901.     { 0,'x',0,&NextGad },
  902.     { 0,'g',0,&AgeGad },
  903.     { 0,'c',0,&CityStateZipGad },
  904.     { 0,'d',0,&AddressGad },
  905.     { 0,'a',0,&NameGad },
  906.     { 0, 0, 0, 0 }
  907. };
  908.  
  909. struct IGMenu CardRequestIGMenuInfo[] =
  910. {
  911.     { 63488, LoadStuff, (UBYTE *)"Project|ProjectItem0" },
  912. { 63520, SaveStuff, (UBYTE *)"Project|ProjectItem1" },
  913. { 63552, Quit, (UBYTE *)"Project|ProjectItem3" },
  914. { 0, 0, 0 }
  915. };
  916.  
  917. struct IGRequest CardRequest =
  918. {
  919.     &NewCardFileWindow,        /* NewWindow */
  920.     NULL,        /* Window */
  921.     (UBYTE *)"Screen Title Here",           /* ScreenName */
  922.     NULL,        /* RequesterToOpen */
  923.     NULL,        /* Requester */
  924.     CardRequestIGMenuInfo,        /* Menus */
  925.     CardRequestEndList,        /* EndList */
  926.     CardRequestCommands,        /* KeyCommands */
  927.     &NameGad,        /* Gadgets */
  928.     IG_ADDGADGETS | IG_RECORDWINDOWPOS,        /* Flags */
  929.     &NameGad,        /* StringToActivate */
  930.     &Project,        /* MenuStrip */
  931.     &CardFileBorderB1,        /* Borders */
  932.     NULL,        /* Images */
  933.     &Title,     /* ITexts */
  934.     NULL,        /* SBoxes */
  935.     NULL,        /* IGObjects */
  936.     NULL,             /* DataStruct */ /* This will be filled in in the main loop */
  937.     NULL,        /* ReqKey */
  938.     NULL,        /* InitFunction */
  939.     0,        /* Terminate */
  940.     NULL,        /* IComPort */
  941.     NULL,        /* InternalData */
  942.     NULL,        /* DSelectFunction */
  943.     NULL,        /* EndFunction */
  944.     NULL,        /* LoopFunction */
  945.     NULL,0,     /* CallLoop, LoopBitsUsed */
  946.     NULL,        /* ArexxPort */
  947.     NULL,        /* ArexxFunction */
  948.     0,NULL,     /* AdditionalSignals, SignalFunction */
  949.     NULL,        /* GUpFunction */
  950.     NULL,        /* GDownFunction */
  951.     NULL,        /* MouseButtons */
  952.     NULL,        /* MouseMove */
  953.     NULL,        /* DeltaMove */
  954.     NULL,        /* RawKey */
  955.     NULL,        /* IntuiTicks */
  956.     NULL,        /* DiskInserted */
  957.     NULL,        /* DiskRemoved */
  958.     NULL,        /* MenuVerify */
  959.     NULL,        /* MenuPick */
  960.     NULL,        /* SizeVerify */
  961.     NULL,        /* NewSize */
  962.     NULL,        /* ReqVerify */
  963.     NULL,        /* ReqSet */
  964.     NULL,        /* ReqClear */
  965.     NULL,        /* ActiveWindow */
  966.     NULL,        /* InActiveWindow */
  967.     NULL,        /* RefreshWindow */
  968.     NULL,        /* NewPrefs */
  969.     NULL,        /* CloseWindow */
  970.     NULL,        /* DoubleClick */
  971.     NULL,        /* OtherMessages */
  972.     NULL        /* UserData */
  973. };
  974.  
  975.  
  976.  
  977. /* We are now at the bottom of the file.  We will import more code here. */
  978.  
  979. /* This is the end of IntuiGen generated code. */
  980.  
  981. void LoadStuff(struct IGRequest *x,struct IntuiMessage *y)
  982. {
  983.     puts ("Loadstuff");
  984. }
  985.  
  986. void SaveStuff(struct IGRequest *x,struct IntuiMessage *y)
  987. {
  988.     puts ("SaveStuff");
  989. }
  990.  
  991. void Quit(struct IGRequest *x,struct IntuiMessage *y)
  992. {
  993.     x->Terminate=1;
  994.     QuitFlag=1;
  995. }
  996.  
  997. /* The preceding functions are the finished versions of the functions
  998.     we prototyped above.  For simplicity, no loading and saving code
  999.     was written, when those menu items are chose, it will just print
  1000.     "LoadStuff" and "SaveStuff" respectively.
  1001. */
  1002.  
  1003. BOOL NewCard ()
  1004. {
  1005.     struct Person *new;
  1006.  
  1007.     new=(void *)AllocRemember(&CardKey,sizeof(struct Person), MEMF_PUBLIC | MEMF_CLEAR);
  1008.     if (!new) return (1);
  1009.     if (OnScreen->Next) OnScreen->Next->Prev=new;
  1010.     new->Next=OnScreen->Next;
  1011.     new->Prev=OnScreen;
  1012.     OnScreen->Next=new;
  1013.     OnScreen=new;
  1014.     return (0);
  1015. }
  1016.  
  1017. /* The Preceding function allocates memory for a new "Card" and adds it
  1018.     to the linked list of cards */
  1019.  
  1020. main ()
  1021. {
  1022.     struct IGEndList *el;
  1023.  
  1024.     /* These two lines are necessary in order to use system library
  1025.     calls on the Amiga */
  1026.  
  1027.     IntuitionBase=OpenLibrary("intuition.library",0);
  1028.     GfxBase=OpenLibrary ("graphics.library",0);
  1029.  
  1030.     if (!IntuitionBase || !GfxBase) goto done;
  1031.  
  1032.     /* Here we open the window (The NewCardFileWindow structure
  1033.     was generated above by IntuiGen). */
  1034.  
  1035.     CardRequest.Window=OpenWindow (&NewCardFileWindow);
  1036.     if (!(CardRequest.Window)) goto done;
  1037.  
  1038.     /* Here we set up our linked list of cards */
  1039.     OnScreen=&CardBase;
  1040.     NewCard ();
  1041.  
  1042.     /* This is the main loop of our program which calls IGRequest
  1043.     to display the current card, will cycle to the next or previous
  1044.     cards if the user chooses gadgets that correspond to those
  1045.     functions, or will create a new card if the user chooses the
  1046.     "New Gadget"
  1047.     */
  1048.  
  1049.     while (!QuitFlag) {
  1050.     CardRequest.DataStruct=(APTR)OnScreen;
  1051.     el=IGRequest (&CardRequest); /* Note that we only
  1052.         have to pass IGRequest one top level structure
  1053.         which has pointers to all the other IntuiGen Generated
  1054.         structures that IGRequest requires to display the requester */
  1055.  
  1056.     if (el->Gadget==&NewGad) NewCard ();
  1057.     else if (el->Gadget==&NextGad && OnScreen->Next)
  1058.         OnScreen=OnScreen->Next;
  1059.     else if (el->Gadget==&PreviousGad && OnScreen->Prev!=&CardBase)
  1060.         OnScreen=OnScreen->Prev;
  1061.     }
  1062.  
  1063.     /* this is our cleaning up code.  It frees the memory, closes the window
  1064.     and closes the system libraries */
  1065. done:
  1066.     if (IntuitionBase) {
  1067.     FreeRemember (&CardRequest.ReqKey,1);
  1068.     FreeRemember (&CardKey,1);
  1069.     if (CardRequest.Window) CloseWindow (CardRequest.Window);
  1070.     CloseLibrary(IntuitionBase);
  1071.     }
  1072.     if (GfxBase) CloseLibrary(GfxBase);
  1073. }
  1074.  
  1075. /* This function, main, (which is where the program will start) initializes
  1076.    the global variables, handles the display of different cards,
  1077.    Calls NewCard to add additional cards to the linked list when
  1078.    necessary, and calls IGRequest.  IGRequest, part of the IntuiGen
  1079.    code, handles all the details of the user interface using the
  1080.    data stored in the IntuiGen functions generated above (by IntuiGen).
  1081.    This makes implementing something simple like a card file, truly simple
  1082.    as the user interface worries are already accounted for.
  1083.  
  1084.    We will now compile this module, and link it with IGRequest.o
  1085. */
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.